package com.lzh.crypt.enums;

import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.IvParameterSpec;
import java.security.spec.AlgorithmParameterSpec;

/**
 * @author zhehen.lu
 * @date 2025/8/10 19:55
 */
public enum AesAlgorithmEnum {

    AES("AES"), AES_128_CBC_PKCS7("AES/CBC/PKCS7Padding"), AES_GCM_NOPADDING("AES/GCM/NoPadding");

    private final String algorithm;

    public String getAlgorithm() {
        return algorithm;
    }

    private AesAlgorithmEnum(String algorithm) {
        this.algorithm = algorithm;
    }

    public AlgorithmParameterSpec generrateParameterSpec(int bitLength, byte[] param) {
        switch (this) {
            case AES:
                return new IvParameterSpec(param);
            case AES_128_CBC_PKCS7:
                return new IvParameterSpec(param);
            case AES_GCM_NOPADDING:
                return new GCMParameterSpec(bitLength, param);
        }
        return null;
    }

}